import { Nodes } from '@knno/dom';

const IV = 'invalid';

export abstract class Validatable extends Nodes {
	invalid(): boolean;
	invalid(value: boolean): this;
	invalid(value?: boolean): boolean | this {
		if (value === undefined) {
			return this.class().includes(IV);
		}
		if (value) {
			this.addClass(IV);
		} else {
			this.removeClass(IV);
		}
		return this;
	}
}
